//
//  MYAlertView.m
//  massage
//
//  Created by 李志权 on 2017/1/20.
//  Copyright © 2017年 李志权. All rights reserved.
//

#import "MYAlertView.h"

@implementation MYAlertView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (id)initWithCoder:(NSCoder *)aDecoder
{
   self = [super initWithCoder:aDecoder];
    UIWindow *window = [[UIApplication sharedApplication]keyWindow];
    self.frame = window.bounds;
    [window addSubview:self];
    self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7];
    self.Y = Height;
    [UIView animateWithDuration:0.25 animations:^{
        self.Y = 0;
    }];
    
    return self;
}
- (IBAction)closeBtnClick:(id)sender {
    [UIView animateWithDuration:0.25 animations:^{
        self.Y = Height;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}
-(void)drawRect:(CGRect)rect
{
    [self.btnTitle setShearRound:6 masksToBounds:YES borderWidth:0 borderColor:nil];
    [self.aView setShearRound:6 masksToBounds:YES borderWidth:0 borderColor:nil];
    [self.btnTitle addTarget:self action:@selector(btnTitleClick) forControlEvents:UIControlEventTouchUpInside];
}
- (void)btnTitleClick
{
    if (self.isClosed) {
        [self closeBtnClick:nil];
    }
    else
    {
        if (self.btnTitleBtnClick) {
            self.btnTitleBtnClick();
        }
    }
}
@end
